<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <p>localStorage 用于长久保存整个网站的数据，保存的数据没有过期时间，直到手动去删除</p>
    <p>sessionStorage 用于临时保存同一窗口(或标签页)的数据，在关闭窗口或标签页之后将会删除这些数据</p>
    
    <p>参考：https://www.runoob.com/jsref/prop-win-localstorage.html</p>
    <script>
       window.onstorage=e=>{//localStorage只有在非当前页修改key值对应的内容才会回调此
            console.log('The ' + e.key + ' key has been changed from ' + e.oldValue + ' to ' + e.newValue + '.');
        }


        console.log("key1="+localStorage.getItem("key1"))
        console.log("key1="+sessionStorage.getItem("s1"))
        localStorage.setItem("key1","value123")
    </script>
</body>
</html>